]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
locatePointer: Add implementation in gnome-shell
authorOlivier Fourdan <ofourdan@redhat.com>
Wed, 20 Feb 2019 09:12:36 +0000 (10:12 +0100)
committerOlivier Fourdan <ofourdan@redhat.com>
Wed, 5 Jun 2019 08:15:10 +0000 (08:15 +0000)
The "locate pointer" functionality was implemented in gnome settings
daemon using X11 protocols and would fail when run under Wayland.

With Wayland, there is no global coordinate space exposed to the clients
so this functionality cannot be implemented as a separate program.

Instead, add the "locate pointer" functionality in gnome-shell so that
it works in both X11 and Wayland.

https://gitlab.gnome.org/GNOME/gnome-shell/issues/981
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/413
https://gitlab.gnome.org/GNOME/mutter/merge_requests/453
https://gitlab.gnome.org/GNOME/gsettings-desktop-schemas/merge_requests/19
https://gitlab.gnome.org/GNOME/gnome-settings-daemon/merge_requests/86

data/theme/gnome-shell-sass/_common.scss
js/js-resources.gresource.xml
js/ui/locatePointer.js [new file with mode: 0644]
js/ui/main.js
src/gnome-shell-plugin.c
src/shell-global-private.h
src/shell-global.c

index 64cc612aa3eddac761864fcfd77a8f1e420af202..c8c53d557ff0e5d652f3c702794eff5662438307 100644 (file)
@@ -1159,6 +1159,15 @@ StScrollBar {
   border: 1px solid $selected_bg_color;
 }
 
+// Pointer location
+.ripple-pointer-location {
+  width: 50px;
+  height: 50px;
+  border-radius: 25px 25px 25px 25px; // radius the size of the box give us the curve
+  background-color: lighten(transparentize($selected_bg_color, 0.7), 30%);
+  box-shadow: 0 0 2px 2px lighten($selected_bg_color, 20%);
+}
+
 // not really top bar only
 .popup-menu-arrow { icon-size: 1.09em; }
 .popup-menu-icon { icon-size: 1.09em; }
index 135b8e885bbd5d0f11d9b3e4273c7a4035a88059..7807cce9db5350e2339187eedfc111051700f245 100644 (file)
@@ -64,6 +64,7 @@
     <file>ui/keyboard.js</file>
     <file>ui/layout.js</file>
     <file>ui/lightbox.js</file>
+    <file>ui/locatePointer.js</file>
     <file>ui/lookingGlass.js</file>
     <file>ui/magnifier.js</file>
     <file>ui/magnifierDBus.js</file>
diff --git a/js/ui/locatePointer.js b/js/ui/locatePointer.js
new file mode 100644 (file)
index 0000000..52a0bc4
--- /dev/null
@@ -0,0 +1,24 @@
+// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
+
+const { Clutter, Gio, GLib, St } = imports.gi;
+const Ripples = imports.ui.ripples;
+const Main = imports.ui.main;
+
+const LOCATE_POINTER_KEY = "locate-pointer";
+const LOCATE_POINTER_SCHEMA = "org.gnome.desktop.interface"
+
+var locatePointer = class {
+    constructor() {
+        this._settings = new Gio.Settings({schema_id: LOCATE_POINTER_SCHEMA});
+        this._ripples = new Ripples.Ripples(0.5, 0.5, 'ripple-pointer-location');
+        this._ripples.addTo(Main.uiGroup);
+    }
+
+    show() {
+        if (!this._settings.get_boolean("locate-pointer"))
+            return;
+
+        let [x, y, mods] = global.get_pointer();
+        this._ripples.playAnimation(x, y);
+    }
+};
index d9f287cd9ded262a38ac40ca5d362340b223023a..b3cd69283a7a1b11afd832acd01ea8c555c7b811 100644 (file)
@@ -37,6 +37,7 @@ const WindowManager = imports.ui.windowManager;
 const Magnifier = imports.ui.magnifier;
 const XdndHandler = imports.ui.xdndHandler;
 const KbdA11yDialog = imports.ui.kbdA11yDialog;
+const LocatePointer = imports.ui.locatePointer;
 
 const A11Y_SCHEMA = 'org.gnome.desktop.a11y.keyboard';
 const STICKY_KEYS_ENABLE = 'stickykeys-enable';
@@ -74,6 +75,7 @@ var layoutManager = null;
 var kbdA11yDialog = null;
 var inputMethod = null;
 var introspectService = null;
+var locatePointer = null;
 let _startDate;
 let _defaultCssStylesheet = null;
 let _cssStylesheet = null;
@@ -92,6 +94,8 @@ function _sessionUpdated() {
     wm.allowKeybinding('overlay-key', Shell.ActionMode.NORMAL |
                                       Shell.ActionMode.OVERVIEW);
 
+    wm.allowKeybinding('locate-pointer-key', Shell.ActionMode.ALL);
+
     wm.setCustomKeybindingHandler('panel-run-dialog',
                                   Shell.ActionMode.NORMAL |
                                   Shell.ActionMode.OVERVIEW,
@@ -165,6 +169,8 @@ function _initializeUI() {
     kbdA11yDialog = new KbdA11yDialog.KbdA11yDialog();
     wm = new WindowManager.WindowManager();
     magnifier = new Magnifier.Magnifier();
+    locatePointer = new LocatePointer.locatePointer();
+
     if (LoginManager.canLock())
         screenShield = new ScreenShield.ScreenShield();
 
@@ -190,6 +196,10 @@ function _initializeUI() {
             overview.toggle();
     });
 
+    global.connect('locate-pointer', () => {
+        locatePointer.show();
+    });
+
     global.display.connect('show-restart-message', (display, message) => {
         showRestartMessage(message);
         return true;
index 35a9a8bcb44f567f22b6d40ba7c1fd4f50a9aba6..2e491646caa7111d493d6fca1decf2cd0ad3790d 100644 (file)
@@ -346,6 +346,13 @@ gnome_shell_plugin_create_inhibit_shortcuts_dialog (MetaPlugin *plugin,
   return _shell_wm_create_inhibit_shortcuts_dialog (get_shell_wm (), window);
 }
 
+static void
+gnome_shell_plugin_locate_pointer (MetaPlugin *plugin)
+{
+  GnomeShellPlugin *shell_plugin = GNOME_SHELL_PLUGIN (plugin);
+  _shell_global_locate_pointer (shell_plugin->global);
+}
+
 static void
 gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
 {
@@ -378,6 +385,8 @@ gnome_shell_plugin_class_init (GnomeShellPluginClass *klass)
 
   plugin_class->create_close_dialog = gnome_shell_plugin_create_close_dialog;
   plugin_class->create_inhibit_shortcuts_dialog = gnome_shell_plugin_create_inhibit_shortcuts_dialog;
+
+  plugin_class->locate_pointer = gnome_shell_plugin_locate_pointer;
 }
 
 static void
index df53236aac54ea01718916891ff87aa13f793c7e..9969691cb47db09ae5c81f043cc609e80f4aa645 100644 (file)
@@ -18,4 +18,6 @@ GjsContext *_shell_global_get_gjs_context (ShellGlobal  *global);
 gboolean _shell_global_check_xdnd_event (ShellGlobal  *global,
                                          XEvent       *xev);
 
+void _shell_global_locate_pointer (ShellGlobal  *global);
+
 #endif /* __SHELL_GLOBAL_PRIVATE_H__ */
index 293053d0b58446125b27db9848a10bf8509ede46..70120c2da834ebc0680925af873f9a84560e3472 100644 (file)
@@ -115,6 +115,7 @@ enum {
 enum
 {
  NOTIFY_ERROR,
+ LOCATE_POINTER,
  LAST_SIGNAL
 };
 
@@ -357,6 +358,13 @@ shell_global_class_init (ShellGlobalClass *klass)
                     G_TYPE_NONE, 2,
                     G_TYPE_STRING,
                     G_TYPE_STRING);
+  shell_global_signals[LOCATE_POINTER] =
+      g_signal_new ("locate-pointer",
+                    G_TYPE_FROM_CLASS (klass),
+                    G_SIGNAL_RUN_LAST,
+                    0,
+                    NULL, NULL, NULL,
+                    G_TYPE_NONE, 0);
 
   g_object_class_install_property (gobject_class,
                                    PROP_SESSION_MODE,
@@ -1732,3 +1740,9 @@ shell_global_get_persistent_state (ShellGlobal  *global,
 {
   return load_variant (global->userdatadir_path, property_type, property_name);
 }
+
+void
+_shell_global_locate_pointer (ShellGlobal *global)
+{
+  g_signal_emit (global, shell_global_signals[LOCATE_POINTER], 0);
+}